using B.S.XZYData.Api.Read.Dto.Plan;
using System;
using System.Collections.Generic;

namespace B.S.XZYData.Api.Read.Dto.WorkOrder
{
    /// <summary>
    /// 工单工序综合信息DTO（按工序展开的综合数据）
    /// </summary>
    public class WorkOrderProcessComprehensiveDto
    {
        /// <summary>
        /// 工单基本信息
        /// </summary>
        public WorkOrderBasicInfo WorkOrder { get; set; } = new WorkOrderBasicInfo();

        /// <summary>
        /// 工序详细信息
        /// </summary>
        public ProcessDetailInfo Process { get; set; } = new ProcessDetailInfo();

        /// <summary>
        /// 产品信息
        /// </summary>
        public ProductBasicInfo Product { get; set; } = new ProductBasicInfo();

        /// <summary>
        /// 计划信息（如果存在）
        /// </summary>
        public PlanBasicInfo? Plan { get; set; }

        /// <summary>
        /// 分派信息列表
        /// </summary>
        public List<AssignInfo> Assigns { get; set; } = new List<AssignInfo>();

        /// <summary>
        /// 进度统计
        /// </summary>
        public ProgressSummary Progress { get; set; } = new ProgressSummary();
    }

    /// <summary>
    /// 工单基本信息
    /// </summary>
    public class WorkOrderBasicInfo
    {
        /// <summary>
        /// 工单ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        public string Code { get; set; } = string.Empty;

        /// <summary>
        /// 工单状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        public int? PlannedQuantity { get; set; }

        /// <summary>
        /// 实际数量
        /// </summary>
        public int? ActualQuantity { get; set; }

        /// <summary>
        /// 良品数量
        /// </summary>
        public int? GoodQuantity { get; set; }

        /// <summary>
        /// 不良品数量
        /// </summary>
        public int? BadQuantity { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime? PlannedStartTime { get; set; }

        /// <summary>
        /// 计划结束时间
        /// </summary>
        public DateTime? PlannedEndTime { get; set; }

        /// <summary>
        /// 实际开始时间
        /// </summary>
        public DateTime? ActualStartTime { get; set; }

        /// <summary>
        /// 实际结束时间
        /// </summary>
        public DateTime? ActualEndTime { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string? CreateBy { get; set; }
    }

    /// <summary>
    /// 工序详细信息
    /// </summary>
    public class ProcessDetailInfo
    {
        /// <summary>
        /// 工序ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 顺序号
        /// </summary>
        public int Sequence { get; set; }

        /// <summary>
        /// 工序编号
        /// </summary>
        public string ProcessCode { get; set; } = string.Empty;

        /// <summary>
        /// 工序名称
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 工序状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        public int? PlannedQuantity { get; set; }

        /// <summary>
        /// 已报工数
        /// </summary>
        public int? ReportedQuantity { get; set; }

        /// <summary>
        /// 良品数
        /// </summary>
        public int? GoodQuantity { get; set; }

        /// <summary>
        /// 不良品数
        /// </summary>
        public int? BadQuantity { get; set; }

        /// <summary>
        /// 报工配比
        /// </summary>
        public decimal? Ratio { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime? PlannedStartTime { get; set; }

        /// <summary>
        /// 计划结束时间
        /// </summary>
        public DateTime? PlannedEndTime { get; set; }

        /// <summary>
        /// 实际开始时间
        /// </summary>
        public DateTime? ActualStartTime { get; set; }

        /// <summary>
        /// 实际结束时间
        /// </summary>
        public DateTime? ActualEndTime { get; set; }
    }

    /// <summary>
    /// 产品基本信息
    /// </summary>
    public class ProductBasicInfo
    {
        /// <summary>
        /// 产品编号
        /// </summary>
        public string? ProductCode { get; set; }

        /// <summary>
        /// 产品名称
        /// </summary>
        public string? ProductName { get; set; }

        /// <summary>
        /// 规格
        /// </summary>
        public string? Spec { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string? Unit { get; set; }
    }

    /// <summary>
    /// 计划基本信息
    /// </summary>
    public class PlanBasicInfo
    {
        /// <summary>
        /// 计划明细ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 计划ID
        /// </summary>
        public int PlanId { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        public int? Quantity { get; set; }

        /// <summary>
        /// 已完成数量
        /// </summary>
        public int? DoneQuantity { get; set; }
    }

    /// <summary>
    /// 分派信息
    /// </summary>
    public class AssignInfo
    {
        /// <summary>
        /// 分派ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 员工ID
        /// </summary>
        public int EmployeeId { get; set; }

        /// <summary>
        /// 员工姓名
        /// </summary>
        public string EmployeeName { get; set; } = string.Empty;

        /// <summary>
        /// 分派数量
        /// </summary>
        public int Quantity { get; set; }
    }

    /// <summary>
    /// 进度统计
    /// </summary>
    public class ProgressSummary
    {
        /// <summary>
        /// 工单完成百分比
        /// </summary>
        public decimal WorkOrderCompletionPercentage { get; set; }

        /// <summary>
        /// 工序完成百分比
        /// </summary>
        public decimal ProcessCompletionPercentage { get; set; }

        /// <summary>
        /// 分派完成情况
        /// </summary>
        public string AssignStatus { get; set; } = string.Empty;

        /// <summary>
        /// 总分派数量
        /// </summary>
        public int TotalAssignQuantity { get; set; }

        /// <summary>
        /// 分派员工数量
        /// </summary>
        public int AssignedEmployeeCount { get; set; }
    }
}
